﻿@model IEnumerable<RMS.Models.User>

@{
    ViewBag.Title = "AllUser";
}

<h2>AllUser</h2>

<table>
    <tr>
        <th>
            UserName
        </th>
        <th>
            Name
        </th>
        <th>
            Company
        </th>
        <th>
            Founder
        </th>
        <th>
            Latest Activity
        </th>
        <th></th>
    </tr>

@foreach (var item in Model)
{
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.UserName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Name)
        </td>
        <td>
            @{try
              {
            @Html.DisplayFor(modelItem => item.Company.Name)
              }
              catch
              {
                  @Html.Encode("-")
              }
            }
                
        </td>

        <td>
            @Html.DisplayFor(modelItem => item.Company.FounderUser.Name)
        </td>

        <td>
            @Html.Encode(Membership.GetUser(item.UserName).LastLoginDate.ToString())
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
            @Html.ActionLink("Details", "Details", new { id=item.Id }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.Id })
        </td>
    </tr>
}

</table>
